Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "buffered-normalized mode", add $buf cell type, and add "bufnorm" command #3967

Merged
merged 11 commits into from
Sep 17, 2024

Conversation

clairexen
Copy link
Member

This PR adds "buffered-normalized mode" to RTLIL. In that mode there's a 1:1 relationship between cell ouput ports and wires, and each wire is annotated with a reference to the cell and cell port driving it.

Once in "buffered-normalized mode" calling design->bufNormalize() (or module->bufNormalize()) will ensure that the above condition is met, by adding additional intermediate wires and buffer cells as needed.

This PR also adds a $buf "coarse-grain" buffer cell type, similar in behavior to $pos, but techmap/simplemap/etc is not mapping this buffer type to an array of single-bit buffers. bufNormalize() is adding buffers of that new $buf type. Note that bufNormalize() is very efficient and only looks at the parts of the design that have been changed since the last time bufNormalize() has been run, i.e. it does not require a complete scan over the design.

This PR also adds the bufnorm command for getting the design into and out of "buffered-normalized mode", with more control over the exact type of network of buffers that is being created.

@clairexen clairexen marked this pull request as draft September 29, 2023 14:10
@povik
Copy link
Member

povik commented Oct 16, 2023

This PR also adds a $buf "coarse-grain" buffer cell type, similar in behavior to $pos, but techmap/simplemap/etc is not mapping this buffer type to an array of single-bit buffers.

FWIW that doesn't seem to be the behavior for $pos cells either

void simplemap_pos(RTLIL::Module *module, RTLIL::Cell *cell)
{
RTLIL::SigSpec sig_a = cell->getPort(ID::A);
RTLIL::SigSpec sig_y = cell->getPort(ID::Y);
sig_a.extend_u0(GetSize(sig_y), cell->parameters.at(ID::A_SIGNED).as_bool());
module->connect(RTLIL::SigSig(sig_y, sig_a));
}

@widlarizer
Copy link
Collaborator

widlarizer commented Jun 5, 2024

Since setPort may bufNormQueue.insert, a Cell* may survive in bufNormQueue beyond when the underlying cell is removed. Repro: rebase this branch onto main (855ac28), then read_rtlil bug.proc.il; bufnorm -update; opt; bufnorm -update segfaults on my linux machine, where bug.proc.il is

autoidx 16

module \bug

  wire width 32 $procmux$14_Y

  wire $procmux$15_CMP

  wire $auto$bugpoint.cc:258:simplify_something$1

  wire width 32 output 1 $auto$bugpoint.cc:258:simplify_something$3

  wire width 30 $auto$bugpoint.cc:258:simplify_something$4

  wire width 32 $auto$bugpoint.cc:258:simplify_something$5

  wire $delete_wire$6

  wire width 32 \pc$next

  cell $mux $procmux$14
    parameter \WIDTH 32
    connect \Y $procmux$14_Y
    connect \S $procmux$15_CMP
    connect \B 0
    connect \A 32'x
  end

  cell $dff $7
    parameter \WIDTH 32
    parameter \CLK_POLARITY 1
    connect \Q $auto$bugpoint.cc:258:simplify_something$3
    connect \D \pc$next
    connect \CLK $auto$bugpoint.cc:258:simplify_something$1
  end

  connect $procmux$15_CMP $delete_wire$6
  connect \pc$next $procmux$14_Y
end

@whitequark
Copy link
Member

oh hey, a new user of bugpoint :D

Copy link
Member

@povik povik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the bufnorm command (which I haven't reviewed so I at least marked it experimental) this looks good to me. There are some outstanding issues (e.g. what Emil points out) but they don't affect all use cases. I am in favor of merging this as is to get the ball moving

@povik povik added the merge-after-jf Merge: PR will be merged after the next Dev JF unless concerns are raised label Sep 11, 2024
@povik povik marked this pull request as ready for review September 11, 2024 10:20
@povik
Copy link
Member

povik commented Sep 17, 2024

Rebased to pull in updated CI

@povik povik merged commit a553b7c into main Sep 17, 2024
37 checks passed
@povik povik deleted the claire/bufnorm branch September 17, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-after-jf Merge: PR will be merged after the next Dev JF unless concerns are raised
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants